package com.lcw.view;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.SPUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.jungly.gridpasswordview.GridPasswordView;

public class PersonActivity extends Activity {

    private android.widget.LinearLayout llfirst;
    private android.widget.LinearLayout llsecond;
    private android.widget.Button btnexit;
    private GridPasswordView gridPasswordView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_person);

        initView();


        gridPasswordView.setOnPasswordChangedListener(new GridPasswordView.OnPasswordChangedListener() {
            @Override
            public void onTextChanged(String psw) {
                // add your code here
            }

            @Override
            public void onInputFinish(String psw) {
                // add your code here
                ToastUtils.showShort("您输入的数字是"+psw);
            }
        });

        boolean isLogin = SPUtils.getInstance().getBoolean("isLogin");

        if (isLogin){
            llsecond.setVisibility(View.VISIBLE);
        }

        btnexit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                llsecond.setVisibility(View.GONE);

                SPUtils.getInstance().put("isLogin",false);

                ActivityUtils.finishActivity(PersonActivity.class);

                ActivityUtils.startActivity(MainActivity.class);
            }
        });

    }

    private void initView() {
        this.btnexit = (Button) findViewById(R.id.btn_exit);
        this.llsecond = (LinearLayout) findViewById(R.id.ll_second);
        this.llfirst = (LinearLayout) findViewById(R.id.ll_first);
        this.gridPasswordView = (GridPasswordView) findViewById(R.id.pswView);
    }
}
